package com.waiter.moximoxi.bean;

import android.content.Context;

import com.waiter.moximoxi.constant.Constant;
import com.waiter.moximoxi.juph.JPushUtils;
import com.waiter.moximoxi.net.API;

import java.io.Serializable;

import cn.yhong.aframework.utils.SpUtils;

/**
 * Created by 17639 on 2020/10/15.
 */

public class UserInfoBean implements Serializable {


    /**
     * token : 4e5dc1106a9cb164eff64f2754c7b93c
     * shop_id : 10001
     * admin_type : 3
     * user : {"id":8,"name":"fuwuyuan1"}
     */

    public String token;
    public int shop_id;
    public int admin_type;
    public UserBean user;

    public static class UserBean implements Serializable{
        /**
         * id : 8
         * name : fuwuyuan1
         */

        public int id;
        public String name;
    }

    public void saveInfo(Context context){
        SpUtils.putData(context, Constant.USER_TOKEN,token);
        SpUtils.putData(context, Constant.USER_ID,user.id);
        SpUtils.putData(context, Constant.USER_NAME,user.name);
        SpUtils.putData(context, Constant.LOGIN_STORE,shop_id);
        SpUtils.putData(context, Constant.IS_LOGIN,true);

        JPushUtils.getInstance().setAlias(API.getDeviceID(context));
    }
}
